#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.

set -e

INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"

if [ "$JOB" = "upstart-job" ]; then
    if [ -z "$1" ]; then
        echo "Usage: upstart-job JOB COMMAND" 1>&2
	exit 1
    fi

    JOB="$1"
    INITSCRIPT="$1"
    shift
else
    if [ -z "$1" ]; then
        echo "Usage: $0 COMMAND" 1>&2
	exit 1
    fi
fi

COMMAND="$1"
shift

if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
	ECHO=echo
else
	ECHO=:
fi

case $COMMAND in
start)
    /opt/fusionnas/app/admin/samba.py start
    ;;
stop)
    /opt/fusionnas/app/admin/samba.py stop
    ;;
restart)
    /opt/fusionnas/app/admin/samba.py stop
    /opt/fusionnas/app/admin/samba.py start
    ;;
*)
    $ECHO "Crazy"
    exit 1
esac
